package cn.ctodb.notebook.wxapp.service.mapper;

import cn.ctodb.notebook.wxapp.domain.*;
import cn.ctodb.notebook.wxapp.service.dto.PicDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity Pic and its DTO PicDTO.
 */
@Mapper(componentModel = "spring", uses = {MessageMapper.class})
public interface PicMapper extends EntityMapper<PicDTO, Pic> {

    @Mapping(source = "message.id", target = "messageId")
    PicDTO toDto(Pic pic);

    @Mapping(source = "messageId", target = "message")
    Pic toEntity(PicDTO picDTO);

    default Pic fromId(Long id) {
        if (id == null) {
            return null;
        }
        Pic pic = new Pic();
        pic.setId(id);
        return pic;
    }
}
